package edu.auctionmart

import edu.auctionmart.User
import edu.auctionmart.Auction
import edu.auctionmart.Item
import edu.auctionmart.ItemCategory
import org.joda.time.DateTime
import static org.junit.Assert.*
import org.junit.*

class AuctionIntegrationTests {

    void testAuction() {
			
		User seller = new User(username: "Russell5", userRealName: "administrator", passwd: "Testinga4b", email: "russell@maine.edu")
		seller.validate()
		seller.save()
		
		Item item = new Item(name: "Movie", description: "Some movie", category: ItemCategory.Electronics, quantity: 1)
		item.validate()
		item.save()
		
		DateTime startTime = new DateTime(2012, 2, 12, 0, 0, 0)
		DateTime endTime = new DateTime(2012, 2, 15, 0, 0, 0)
				
		Auction auction = new Auction(auctionTitle: "Title", startBid: 0.01, seller: seller, item: item, startTime: startTime, endTime: endTime, status: AuctionStatus.OnGoing)
		auction.validate()
        auction.save()
		
		def foundAuction = Auction.get(auction.id)
		assertNotNull(foundAuction)
    }

}
